package com.fqgj.xjd.user.dao.impl;
import com.fqgj.common.api.Page;
import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.xjd.user.dao.UserLevelActionFlowDao;
import com.fqgj.xjd.user.entity.UserLevelActionFlowEntity;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* User: frank
* Date: 2020-04-14
* Time: 11:44:17.531
*/

@Repository
public class UserLevelActionFlowDaoImpl extends AbstractBaseMapper<UserLevelActionFlowEntity> implements UserLevelActionFlowDao {

    @Override
    public List<UserLevelActionFlowEntity> getUserLevelActionFlowList(String userCode, Integer type) {
        Map<String, Object> param = new HashMap<>();
        param.put("userCode", userCode);
        param.put("type", type);
        return getSqlSession().selectList(getStatement("getUserLevelActionFlowList"), param);
    }

    @Override
    public List<UserLevelActionFlowEntity> getUserLevelActionFlowListByPage(String userCode, Integer type, Integer rewardType, Page page) {
        Map<String, Object> param = new HashMap<>();
        param.put("page", page);
        param.put("userCode", userCode);
        param.put("type", type);
        param.put("rewardType", rewardType);
        page.setTotalCount(getSqlSession().selectOne("countUserLevelAction", param));
        return getSqlSession().selectList(getStatement("getUserLevelActionFlowListByPage"), param);
    }

    @Override
    public List<UserLevelActionFlowEntity> getUserLevelActionFlowListByDate(String userCode, Integer type, Date currentDate) {
        Map<String, Object> param = new HashMap<>();
        param.put("userCode", userCode);
        param.put("type", type);
        param.put("currentDate", currentDate);
        return getSqlSession().selectList(getStatement("getUserLevelActionFlowListByDate"), param);
    }

    @Override
    public List<UserLevelActionFlowEntity> getUserLevelActionFlowListBetweenDate(String userCode, Integer type, Date startDate, Date endDate) {
        Map<String, Object> param = new HashMap<>();
        param.put("userCode", userCode);
        param.put("type", type);
        param.put("startDate", startDate);
        param.put("endDate", endDate);
        return getSqlSession().selectList(getStatement("getUserLevelActionFlowListBetweenDate"), param);
    }
}